package com.atguigu.cloud.service.impl;

import com.atguigu.cloud.entities.Article;
import com.atguigu.cloud.mapper.ArticleMapper;
import com.atguigu.cloud.service.ArticleService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ArticleServiceImpl implements ArticleService {
    @Resource
    private ArticleMapper articleMapper;

    @Override
    public int add(Article article) {
        return articleMapper.insertSelective(article);
    }

    @Override
    public int delete(Integer id) {
        return articleMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int update(Article article) {
        return articleMapper.updateByPrimaryKeySelective(article);
    }

    @Override
    public Article getById(Integer id) {
        return articleMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Article> getAll() {
        return articleMapper.selectAll();
    }
}
